﻿/******************************************************   
创建者: 梁家健
创建时间: 2017-04-25
修改:
修改时间: 
功能: 企划结果汇总导出
 ******************************************************/

using System;
using System.Collections.Generic;
using System.ComponentModel.Composition;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using com.nm.library.Excels;
using NDF.Utilities;

namespace PlanAPI.Export
{
    [Export(typeof(ExcelImport))]
    public class PLItemSkcForPC : ExcelImport
    {
        public override ExcelImportType Type => ExcelImportType.PLITEMSKCFORPC;
        public override Dictionary<string, ImportVerify> DictFields => _dictFields;

        private Dictionary<string, ImportVerify> _dictFields = new List<ImportVerify> {
            new ImportVerify{ ColumnName="年份",FieldName="Yearv",DataType=typeof(long),VerifyFunc =(e,extra)=> ExcelImportHelper.GetCellMsg(e.CellValue,e.ColName,100,true,true)},
            new ImportVerify{ ColumnName="所属月份",FieldName="Monthv" ,DataType=typeof(long),VerifyFunc=(e,extra)=> ExcelImportHelper.GetCellMsg(e.CellValue,e.ColName,100,true,true)},
            new ImportVerify{ ColumnName="周",FieldName="Weekv",DataType=typeof(long),VerifyFunc =(e,extra)=> ExcelImportHelper.GetCellMsg(e.CellValue,e.ColName,100,true,true)},
            new ImportVerify{ ColumnName="商品区域",FieldName="ParentAreaName",DataType=typeof(string),VerifyFunc =(e,extra)=> ExcelImportHelper.GetCellMsg(e.CellValue,e.ColName,100,true,true)},
            new ImportVerify{ ColumnName="店铺",FieldName="ShopName",DataType=typeof(string),VerifyFunc =(e,extra)=> ExcelImportHelper.GetCellMsg(e.CellValue,e.ColName,100,true,true)},
            new ImportVerify{ ColumnName="系列",FieldName="SeriesName",DataType=typeof(string),VerifyFunc =(e,extra)=> ExcelImportHelper.GetCellMsg(e.CellValue,e.ColName,100,true,true)},
            new ImportVerify{ ColumnName="商品层",FieldName="MaterialProperty",DataType=typeof(string),VerifyFunc =(e,extra)=> ExcelImportHelper.GetCellMsg(e.CellValue,e.ColName,100,true,true)},
            new ImportVerify{ ColumnName="品类",FieldName="ModelName",DataType=typeof(string),VerifyFunc =(e,extra)=> ExcelImportHelper.GetCellMsg(e.CellValue,e.ColName,100,true,true)},
            new ImportVerify{ ColumnName="小品类",FieldName="ItemName",DataType=typeof(string),VerifyFunc =(e,extra)=> ExcelImportHelper.GetCellMsg(e.CellValue,e.ColName,100,true,true)},
            new ImportVerify{ ColumnName="深度",FieldName="DeepQty",DataType=typeof(long?),VerifyFunc =(e,extra)=> ExcelImportHelper.GetCellMsg(e.CellValue,e.ColName,100,true,true)},
            new ImportVerify{ ColumnName="价格带",FieldName="PriceColorName",DataType=typeof(string),VerifyFunc =(e,extra)=> ExcelImportHelper.GetCellMsg(e.CellValue,e.ColName,100,true,true)},
            new ImportVerify{ ColumnName="企划金额",FieldName="SumPrice",DataType=typeof(decimal?),VerifyFunc =(e,extra)=> ExcelImportHelper.GetCellMsg(e.CellValue,e.ColName,50,false,true)},
            new ImportVerify{ ColumnName="SKC数汇总",FieldName="SumSKC" ,DataType=typeof(long?),VerifyFunc=(e,extra)=> ExcelImportHelper.GetCellMsg(e.CellValue,e.ColName,200,false,true)},
           }.ToDictionary(e => e.ColumnName, e => e);

        public override object SaveImportData(DataTable dt, Dictionary<string, object> extraInfo, int userId)
        {
            throw new NotImplementedException();
        }

        public override DataTable GetExportData(string Keys)
        {
            var list = Keys.Split("other.", StringSplitOptions.RemoveEmptyEntries);
            var CountryAreaCity = 0;
            if (list[1].Contains("isArea"))
            {
                CountryAreaCity = 1;
            }else if (list[1].Contains("isShop"))
            {
                CountryAreaCity = 2;
            }
            var isWeek = list[1].Contains("isWeekv");
            var isSeries = list[1].Contains("isSeries");
            var isMaterialProperty = list[1].Contains("isMaterialProperty");
            var isModel = list[1].Contains("isModel");
            var isItem = list[1].Contains("isItem");
            var isDeep = list[1].Contains("isDeep");
            var isPrice = list[1].Contains("isPrice");
            return new PLItemSkcForPCHandler().ExportPLItemSkcForPC(list[0].Substring(0, list[0].Length - 4), CountryAreaCity, isWeek, isSeries, isMaterialProperty, isModel, isItem, isDeep, isPrice);
        }
    }
}
